<div id="adminpagepanel">
    <h2>Bills Management</h2>
    <?php echo validation_errors();?>
    <?php if(!empty($savemessage)){ echo $savemessage;}?>
    <?php echo form_open_multipart('../admin/index.php/module/track/', array('name'=>'frm','id'=>'frm'));?>
    <table class="adminformtable">
        <tr>
            <th colspan="2" style="text-align:left;padding-left:15px">Add Record</th>
        </tr>
        <tr>
            <td valign="top">
                <table cellpadding="0" cellspacing="0" border="0">
                    <tr>
                        <td class="title">Bill Number*</td>
                        <td><input type="text" name="bill_number" id="dep_name" value="<?=(isset($editdata['bill_number']) ? $editdata['bill_number'] : '');?>" style="width:250px;" /></td>
                    </tr> 
                    <tr>
                        <td class="title">Origin*</td>
                        <td><input type="text" name="origin" value="<?=(isset($editdata['origin']) ? $editdata['origin'] : '');?>" style="width:250px;" /></td>
                    </tr>
                    <tr>
                        <td class="title">Destination*</td>
                        <td><input type="text" name="destination" value="<?=(isset($editdata['destination']) ? $editdata['destination'] : '');?>" style="width:250px;" /></td>
                    </tr>
                    <tr>
                        <td class="title">Container no*</td>
                        <td><input type="text" name="container_id" value="<?=(isset($editdata['container_id']) ? $editdata['container_id'] : '');?>" style="width:250px;" /></td>
                    </tr>
                    <tr>
                        <td class="title">Bill Of Lading</td>
                        <td><input type="text" name="bill_of_lading" value="<?=(isset($editdata['bill_of_lading']) ? $editdata['bill_of_lading'] : '');?>" style="width:250px;" /></td>
                    </tr>
                    <tr>
                        <td class="title">Shipper</td>
                        <td><input type="text" name="shipper" value="<?=(isset($editdata['shipper']) ? $editdata['shipper'] : '');?>" style="width:250px;" /></td>
                    </tr>
                    <tr>
                        <td class="title">Consignee</td>
                        <td><input type="text" name="consignee" value="<?=(isset($editdata['consignee']) ? $editdata['consignee'] : '');?>" style="width:250px;" /></td>
                    </tr>
                    
                </table>
            </td>
            <td valign="top">
                <table cellpadding="0" cellspacing="0" border="0">
                    <tr>
                        <td class="title" valign="top">Consignor</td>
                        <td><input type="text" name="consignor" id="dep_name" value="<?=(isset($editdata['consignor']) ? $editdata['consignor'] : '');?>" style="width:250px;" /></td>
                    </tr>        
                    <tr>
                        <td class="title" valign="top">No of containers</td>
                        <td><input type="text" name="containers_no" id="dep_name" value="<?=(isset($editdata['containers_no']) ? $editdata['containers_no'] : '');?>" style="width:250px;" /></td>
                    </tr>        
                    <tr>
                        <td class="title" valign="top">Weight</td>
                        <td><input type="text" name="weight" id="dep_name" value="<?=(isset($editdata['weight']) ? $editdata['weight'] : '');?>" style="width:250px;" /></td>
                    </tr>        
                    <tr>
                        <td class="title" valign="top">RAR</td>
                        <td><input type="text" name="rar" id="dep_name" value="<?=(isset($editdata['rar']) ? $editdata['rar'] : '');?>" style="width:250px;" /></td>
                    </tr>        
                    <tr>
                        <td class="title" valign="top">Duty</td>
                        <td><input type="text" name="duty" id="dep_name" value="<?=(isset($editdata['duty']) ? $editdata['duty'] : '');?>" style="width:250px;" /></td>
                    </tr>        
                    <tr>
                        <td class="title" valign="top">Estimated Delivery Date:</td>
                        <td><input type="text" name="edd" id="dep_name" value="<?=(isset($editdata['edd']) ? $editdata['edd'] : '');?>" style="width:150px;" placeholder="<?=date('Y-m-d');?>" /> <font style="color:#666666;">Hint: yyyy-mm-dd</font></td>
                    </tr>                            
                </table>
            </td>
        </tr>
       <tr align="right">
            <td colspan="2" style="text-align:right;"><input type="submit" name="btnSubmit" id="btnSubmit" class="panellinks" value="Save" /> </td>
       </tr>
    </table>
    <input type="hidden" name="editid" value="<?=(isset($editdata['id']) ? $editdata['id'] : '');?>" />
    </form>    
    <table width="" class="adminlistingtable" style="width: 100%;">
        <thead>
        <tr>
            <th>ID</th>
            <th>Bill Number</th>
            <th>Origin</th>
            <th>Destination</th>
            <th>Delivered</th>
            <th>Action</th>            
        </tr>
    </thead>
    <?php
    if(isset($track_list) && !empty($track_list)){
        $publish_img =  base_url()."adminimages/publish.png";
        $unpublish_img =  base_url()."adminimages/unpublish.png";
    ?>
        <tbody>
    <?php 
	$i=1;
	foreach($track_list as $tlist){?>
    <tr>
        <td><?=$i;?></td>
        <td><?=$tlist['bill_number']?></td>
        <td><?=$tlist['origin']?></td>
        <td><?=$tlist['destination']?></td>
        <td style="text-align: center;"><a class="listinglink"><?=($tlist['status']==1 ? 'Published':'Unpublish');?></a></td>
        <td >
            <a class="listinglink" href="<?php echo base_url(); ?>admin/index.php/module/track/<?=$tlist['id'];?>">Edit</a>            
            <a class="listinglink" onclick="return del()" href="<?php echo base_url(); ?>admin/index.php/module/del_track/<?=$tlist['bill_number'];?>">Delete</a>
        </td>
    </tr>
    <?php $i++; }?>
    </tbody>
    <?php
    }else{?>
    <tr>
        <td colspan="4"><strong>No bill saved yet</strong></td>
    </tr>
    <?php }?>
    </table>
</div>
<script>
function del(){
    return confirm('Are you sure you want to delete this?');
}
</script>
